package com.buyantech.smweb.service;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.List;

import javacommon.base.BaseManager;
import javacommon.base.EntityDao;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.org.rapid_framework.page.Page;

import com.buyantech.smweb.dao.SettingDao;
import com.buyantech.smweb.dao.UserDao;
import com.buyantech.smweb.model.Setting;
import com.buyantech.smweb.model.User;
import com.buyantech.smweb.vo.query.UserQuery;

/**
 * @author Albert email:albert(a)buyantech.com
 * @version 1.0
 * @date 2012-05-10
 */


@Service
@Transactional
public class SettingManager extends BaseManager<Setting,java.lang.String>{

	private SettingDao settingDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public static  int usernum;
	public static   int usernum1;
	public static   int usernum2;
	public static   int num;
	public static  int integral ;
	public static int ratio;
	public static int QBnumD ;
	public static int QBnumM ;
	public static int HFnumD ;
	public static int HFnumM ;
	public static int numMax ;
	public static int vipnum ;
	public static double exchange;
	public static String updateInfo;
	public static String interval;
	public static int pushInterval;
	public static String recharge;
	
	@Override
	public EntityDao getEntityDao() {
		return this.settingDao;
	}

	public void setSettingDao(SettingDao settingDao) {
		this.settingDao = settingDao;
		
		List<Setting> list=settingDao.getHql("from Setting ");
		if(list!=null&&list.size()>0){
			for(Setting set:list){
				
				if(set.getText()!= null){
					
					String text=set.getText();
					String type=set.getTypes();
			
					if(type.equals("ratio"))
						 ratio = Integer.parseInt(text);
					else if(type.equals("integral"))
						integral = Integer.parseInt(text);
					else if(type.equals("usernum"))
						usernum = Integer.parseInt(text);
					else if(type.equals("usernum1"))
						usernum1 = Integer.parseInt(text);
					else if(type.equals("usernum2"))
						usernum2 = Integer.parseInt(text);
					else if(type.equals("num"))
						num = Integer.parseInt(text);
					else if(type.equals("QBnumD"))
						QBnumD = Integer.parseInt(text);
					else if(type.equals("QBnumM"))
						QBnumM = Integer.parseInt(text);
					else if(type.equals("HFnumD"))
						HFnumD = Integer.parseInt(text);
					else if(type.equals("HFnumM"))
						HFnumM = Integer.parseInt(text);
					else if(type.equals("numMax"))
						numMax = Integer.parseInt(text);
					else if(type.equals("exchange"))
						exchange = Double.parseDouble(text);
					else if(type.equals("updateInfo"))
						updateInfo = text;
					else if(type.equals("vipnum"))
						vipnum = Integer.parseInt(text);
					else if(type.equals("interval"))
						interval = text;
					else if(type.equals("pushInterval"))
						pushInterval = Integer.parseInt(text);
					else if(type.equals("recharge"))
						recharge = text;
					
				}
				
			}
		
			
		}
	}

	public Setting getType(String type){
		List<Setting> list=settingDao.getHql("from Setting where types ='"+type+"'");
		if(list!=null&&list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}
}
